package com.gombe.credit.app.ui.adapter

import androidx.recyclerview.widget.RecyclerView
import com.gombe.credit.app.R
import com.gombe.credit.app.utils.GombeCreditImageLoader
import com.gombe.credit.lib.adapter.GombeCreditRecyclerViewAdapter
import com.gombe.credit.lib.adapter.GombeCreditViewHolderHelper
import com.gombe.credit.lib.shapeview.layout.GombeCreditConstraintLayout
import org.json.JSONObject

/**
 * GombeCredit
 * @Author wwdeng
 * @CreateTime: 2025/3/26 14:28
 * @Annotation：
 */
class AdapterGombeCreditStepWalletComplete(recyclerView: RecyclerView?) : GombeCreditRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.dialog_gombe_credit_step_wallet_submit_complete_item) {
    override fun setItemChildListener(helper: GombeCreditViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.itemLayout) //点击Item
    }
    override fun fillData(helper: GombeCreditViewHolderHelper, position: Int, model: JSONObject) {
        val walletDesc = model.optString("walletDesc")
        helper.setText(R.id.walletTypeTitle,walletDesc)
        helper.setText(R.id.walletAccountMobile,"+" + model.optString("walletMobile"))
        val walletTypeLogo = helper.getImageView(R.id.walletTypeLogo)
        GombeCreditImageLoader.instance?.loadImageUrl(mContext,walletTypeLogo,model.optString("walletLogo"), R.mipmap.gombe_credit_image_holder)

        val itemLayout = helper.getView<GombeCreditConstraintLayout>(R.id.itemLayout)
        if (walletDesc.uppercase().startsWith("W")){
            itemLayout.shapeDrawableBuilder
                .setSolidColor(getColor(R.color.gombe_credit_FFF1FCFF))
                .setStrokeColor(getColor(R.color.gombe_credit_FFDCF7FF))
                .intoBackground()
        } else {
            itemLayout.shapeDrawableBuilder
                .setSolidColor(getColor(R.color.gombe_credit_FFFFF6F1))
                .setStrokeColor(getColor(R.color.gombe_credit_FFFFE9DC))
                .intoBackground()
        }
    }
}